package com.lineage.data.item_etcitem;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Object;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.utils.L1SpawnUtil;
import com.lineage.server.world.World;
import java.util.Iterator;

public class Fuel extends ItemExecutor {
  public static ItemExecutor get() {
    return new Fuel();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    Iterator<L1Object> iterator = World.get().getVisibleObjects((L1Object)pc, 3).iterator();
    while (iterator.hasNext()) {
      L1Object object = iterator.next();
      if (object instanceof com.lineage.server.model.Instance.L1EffectInstance && ((L1NpcInstance)object).getNpcTemplate().get_npcId() == 81170) {
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(1162));
        return;
      } 
    } 
    int[] loc = new int[2];
    loc = pc.getFrontLoc();
    L1SpawnUtil.spawnEffect(81170, 600, loc[0], loc[1], pc.getMapId(), null, 0);
    pc.getInventory().removeItem(item, 1L);
  }
}
